// pages/enter/enter.js
var app=getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo: '',
    active: '',
    index: '',
    pUrl:'',
    value:'',
    page:'',
    pageId:''
  },
  bingInputFunc: function(e){
    if(e.detail.value == ''){
      this.setData({
        active: ''
      })
    }
    else{
      this.setData({
        active: 'active'
      })
    }
  },
  bindFormSubmit: function (e) {
    if (this.data.page == '10'){
      wx.request({
        url: app.globalData.httpApiCar + 'recruitPersonalInfo/update', //仅为示例，并非真实的接口地址
        method: 'POST',
        header: {
          'content-type': 'application/x-www-form-urlencoded' // 默认值
        },
        data: { 
          id: this.data.pageId,
          resumeName:e.detail.value.con
        },
        success: function (res) {
          if (res.data.success) {
            // wx.redirectTo({
            //   url: '/pages/recruitMine/recruitMine',
            // })
            wx.navigateBack({
              delta:1
            })
          }
          else {
            wx.showToast({
              title: res.data.error,
              icon: 'none',
              duration: 2000
            })
          }
        }
      })
    }else{
      if (this.data.pUrl != '') {
        wx.redirectTo({
          url: this.data.pUrl + '?con=' + e.detail.value.con + '&index=' + this.data.index
        });
      } else if (this.data.tag != undefined) {
        wx.navigateTo({
          url: '../../pages/carInfo/carInfo?con=' + e.detail.value.con + '&index=' + this.data.index
        });
      }
      else {
        wx.navigateTo({
          url: '../../pages/enterInfo/enterInfo?con=' + e.detail.value.con + '&index=' + this.data.index
        });
      }
    }
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if(options.page=='10'){
      wx.setNavigationBarTitle({
        title: '简历名称'
      })
      this.setData({
        value: options.value,
        active: options.value?'active':'',
        page:'10',
        pageId: options.id,
      })
    }else{
      if (options.value) {
        this.setData({
          value: options.value,
          active: 'active'
        })
      }
      if (options.url) {
        this.data.pUrl = options.url;
      }
      wx.setNavigationBarTitle({
        title: options.label
      })
      this.setData({
        userInfo: JSON.parse(wx.getStorageSync('userInfo')),
        index: options.index,
        tag: options.tag,
        pUrl: this.data.pUrl
      })
    }
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})